<!DOCTYPE html>
<html>
<body>

	<p>JavaScript can write directly into the HTML output stream:</p>

	<script>
		document.write("<h1>This is a heading</h1>");
		document.write("<p>This is a paragraph.</p>");
	</script>

	<p>
		You can only use <strong>document.write</strong> in the HTML output.
		If you use it after the document has loaded (e.g. in a function), the
		whole document will be overwritten.
	</p>
	<script>
		document.write("raz test");
	</script>

	<button type="button" onclick="alert('Welcome!')">Click Me!</button>

	<p id="demo">JavaScript can change the content of an HTML element.
	</p>

	<script>
		function myFunction() {
			x = document.getElementById("demo"); // Find the element
			x.innerHTML = "Hello JavaScript!"; // Change the content
		}
		
		function change(){
			document.write("raz test");
		}
	</script>

	<button type="button" onclick="myFunction()">Click Me!</button>
	
	<button type="button" onclick="change()">This will overwrite the whole document!</button>

</body>
</html>
